package com.zhao.uitl;

import com.zhao.model.Fruit;

import java.math.BigDecimal;
import java.util.Map;

public class Utils {

    /**
     * 根据水果的重量，计算不考虑任何策略下的总价
     */
    public static BigDecimal getTotalPrice(Map<Fruit, Integer> fruitQuantities) {
        BigDecimal totalPrice = BigDecimal.ZERO;
        for (Map.Entry<Fruit, Integer> entry : fruitQuantities.entrySet()) {
            Fruit fruit = entry.getKey();
            int quantity = entry.getValue();
            totalPrice = totalPrice.add(fruit.getPrice().multiply(BigDecimal.valueOf(quantity)));
        }
        return totalPrice;
    }
}
